package com.msw.jcwapi.wb.wbjyz.controller;


import com.msw.jcwapi.common.result.Result;
import com.msw.jcwapi.wb.wbdz.entity.Wbdz;
import com.msw.jcwapi.wb.wbdz.service.IWbdzService;
import com.msw.jcwapi.wb.wbjyz.entity.Wbjyz;
import com.msw.jcwapi.wb.wbjyz.service.IWbjyzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2025-04-01
 */
@RestController
@RequestMapping("/wbjyz")
public class WbjyzController {

    @Autowired
    IWbjyzService wbjyzService;

    //通过工程id查询全部绝缘子
    @GetMapping("/list/{id}")
    public Result list(@PathVariable Integer id) {
        return Result.ok(wbjyzService.listByProId(id));
    }

    //通过wbjyzid删除该绝缘子
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id) {
        return Result.ok(wbjyzService.deleteById(id));
    }

    //通过wbjyzid查询该绝缘子的全部信息
    @GetMapping("/listByWbjyzId/{id}")
    public Result listByWbjyzId(@PathVariable Integer id) {
        return Result.ok(wbjyzService.listByWbjyzId(id));
    }

    //编辑腕臂绝缘子(通过id编辑)
    @PutMapping
    public Result update(@RequestBody Wbjyz wbjyz){
        return  Result.ok(wbjyzService.update(wbjyz));
    }

    //添加腕臂绝缘子
    @PostMapping
    public Result save(@RequestBody Wbjyz wbjyz){
        return Result.ok(wbjyzService.add(wbjyz));
    }

}
